package net.maku.utils;

import com.wechat.pay.java.core.RSAAutoCertificateConfig;
import com.wechat.pay.java.core.notification.NotificationParser;
import com.wechat.pay.java.core.notification.RequestParam;
import com.wechat.pay.java.service.payments.model.Transaction;

public class TestMain {

	public static void main(String[] args) {
		
		String originalString = "Hello\nWorld\nThis is a test.";
		String replacedString = originalString.replaceAll("\n", "<br />");
		System.out.println(replacedString);
		
		
		/*
		String result = "{\"id\":\"4d519987-e3be-5c94-b55f-0b5f7017eaa3\",\"create_time\":\"2024-09-15T19:02:27+08:00\",\"resource_type\":\"encrypt-resource\",\"event_type\":\"TRANSACTION.SUCCESS\",\"summary\":\"支付成功\",\"resource\":{\"original_type\":\"transaction\",\"algorithm\":\"AEAD_AES_256_GCM\",\"ciphertext\":\"yWgNXQCOiUUN+WyIVLltkilvADGwl5hrKufPPf3v1csCRNFqEwm/x9nfBa7hQLSNwQJaKi/7O3O6J65pEg2L/iuuUObRdybKn5BSkotne6IQAe8dXQGEzLktpTNKzqoFq/FvwQyUxll1sEsEFxzl9uJHTB4xctYuuY4vu7bhK/JdKQVkHr7C8+Eqn8wJhAS4Ne9GupxyU1apQLymISbTHMdsF7+aF59kJoGL7h11CYlkKWXitIU614+DlUuaglNYmMchpNBmnrnCPXR1jETH37Tj830+rhU76Iw/BTr5DqDYdTlBpdEHOOB1QmRWxp52V0kWLsGUATEVTUBaZZZjKXXs+1+f0XeAu0EmWB1rYEnG08leaLAssSFOMJdqoVzVoql2uqvtBekdT/0g6/FmWtkC7LiG7wEr820gus5JomWhYfRLxmUiODzDFVPSzCVo5Cl3EpU8WyEb0M4DFULl67Hg/bjNPGjO9sxrBcxlgBtmxdC2Dixp3BHuQ2KJoAd9oTzuLkJXQtTPy7Y9YMXtzlf69J/Z3ESOY//WYbXume0fjoM8vhqmufO5uw+g0QUo\",\"associated_data\":\"transaction\",\"nonce\":\"4RIk6ppt5daM\"}}";
		String nonce = "dnd1FYqVdbykNObmKiWovZ9HPwjMCewU";
		String serial = "7BD20EE161296EF0F837D2B8A34E924047064E6B";
		String signature = "eoWH1LSqyN/OqIn9xHr1BQleWohwWzcP1sM2SM9ZssMxv4m6+DOfrzBaD3843CE7Bu+dJBebDJplggCGww3L2N72wrgJsNU/wJ6ltHDoA7j5XI94HLG1FGJ1gWqxASRTReek8wP2wya2F1/tOrn+1dOR89U3Lc4PbJ1fi+g4snQLIdd9aL7BaOFvhhonnKrFFr2z+AziyopfrDDdkfqouLi2MIZBPuLGrfri0pXeiBHDC/PXp2b79XQE/TnGK/lQgjnbuUumf1nTW6bRKW4ITDk35+AI1DAcRwPPypdEv6CyakTuuHnQwOgbOidEWbi4QirVhaxi0WbsF1o/0DkX0g==";
		String signType = "WECHATPAY2-SHA256-RSA2048";
		String timestamp = "1726398148";
		
		
	     // 获取HTTP请求头中的 Wechatpay-Signature 、 Wechatpay-Nonce 、 Wechatpay-Timestamp 、 Wechatpay-Serial 、 Request-ID 、Wechatpay-Signature-Type 对应的值，构建 RequestParam 。
        RequestParam requestParam = new RequestParam.Builder()
                .serialNumber(serial)
                .nonce(nonce)
                .signature(signature)
                .timestamp(timestamp)
                // 若未设置signType，默认值为 WECHATPAY2-SHA256-RSA2048
                .signType(signType)
                .body(result)
                .build();
 
        String apiV3key = "oXi4b7pE7YU5QRXCHC30tx5yfXJCAyyC";
        String merchantId = "1676811007";
        //String privateKeyPath = "/home/jishu/bin/cert/apiclient_key.pem";
        String privateKeyPath = "D:\\workspaces\\workspace202409\\duxinai-end\\cert\\apiclient_key.pem";

        String merchantSerialNumber = "3C8BB16E5EDCBDF6C814AC5276F239401AC401D3";
        
        RSAAutoCertificateConfig config = new RSAAutoCertificateConfig.Builder()
                .merchantId(merchantId)
                //.privateKey(wxPayConfig.getPrivateKey())
                .privateKeyFromPath(privateKeyPath)
                .merchantSerialNumber(merchantSerialNumber)
                .apiV3Key(apiV3key)
                .build();
 
        NotificationParser parser = new NotificationParser(config);
        Transaction transaction = parser.parse(requestParam, Transaction.class);
    	System.out.println( transaction.toString() );
    	
    	System.out.println(transaction.getOutTradeNo() );
    	System.out.println( transaction.getTransactionId() );
  */
    	
    	

	
	}

}
